#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
using namespace std;

void heapify(vector<int> &heap, int i)
{
        int l = i >> 1;
        int r = (i >> 1) + 1;
        int minist = 0;

        if(l < heap.size() && heap[l] < heap[i]){
                minist = l;
        }else{
                minist = i;
        }

        if(r < heap.size() && heap[r] < heap[i]){
                minist = r;
        }

        if(minist != i){
                swap(heap[i], heap[minist]);
                heapify(heap, minist);
        }
}

void build_heap(vector<int> &heap)
{
        for(int i = (heap.size() - 1) >> 1; i > 0; i--){
                heapify(heap, i);
        }
}

int mininum(vector<int> &heap)
{
        return heap[1];
}

int extract_min(vector<int> &heap)
{
        int minnum = heap[1];
        heap[1] = heap.back();
        heap.pop_back();
        heapify(heap, 1);
        return minnum;
}

void decrease(vector<int> &heap, int i, int key)
{
        heap[i] = key;
        while(i > 1 && heap[i] < heap[i >> 1]){
                swap(heap[i], heap[i >> 1]);
                i = i >> 1;
        }
}

void insert(vector<int> &heap, int key)
{
        
        heap.push_back(INT32_MAX);
        decrease(heap, heap.size() - 1, key);
} 

int main()
{
        vector<int> heap = {10, 4, 9, 5, 2, 6};
        make_heap(heap.begin(), heap.end());
        cout << heap.back() << endl;

        return 0;
}
